package com.xindacloud.sms.adapter.utils;

import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.HashMap;
import java.util.Map;


public enum AgentEnum {

    NEXMO_AGENT("nexmo", "AG_BE_001"),
    SINCH_AGENT("sinch", "AG_BE_002"),
    CM_AGENT("cm", "AG_BE_003"),
    DOMESTIC_AGENT("domestic", "AG_BE_003"),
    UNKNOWN("unknown", "UNKNOWN");

    private String agentName;
    private String agentErrorCode;

    AgentEnum(String agentName, String agentErrorCode) {
        this.agentName = agentName;
        this.agentErrorCode = agentErrorCode;
    }


    private static final Map<String, AgentEnum> AGENT_ENUM_MAP = new HashMap<>();

    static {
        for (AgentEnum agentEnum : AgentEnum.values()) {
            AGENT_ENUM_MAP.put(agentEnum.agentName, agentEnum);
        }
    }


    @JsonCreator
    public static AgentEnum fetchAgentEnum(String agentName) {
        AgentEnum foundStatus = AGENT_ENUM_MAP.get(agentName);
        return (foundStatus != null) ? foundStatus : UNKNOWN;
    }

    public String getAgentName() {
        return agentName;
    }

    public String getAgentErrorCode() {
        return agentErrorCode;
    }


}
